<!--
  用户管理-企业用户-企业用户列表
 -->
<template>
  <div class="app-container">
    <!-- 搜索工作栏 -->
    <el-form
      v-show="showSearch"
      ref="queryForm"
      :model="queryParams"
      size="small"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="企业申请人姓名" prop="applyUserName">
        <el-input
          v-model="queryParams.applyUserName"
          placeholder="请输入企业申请人姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="企业名称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入企业名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="认证状态" prop="status">
        <el-select
          v-model="queryParams.status"
          placeholder="请选择企业状态"
          clearable
          size="small"
        >
          <el-option
            v-for="dict in this.getDictDatas(DICT_TYPE.COMPANY_STATUS)"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="手机号" prop="phoneNumber">
        <el-input
          v-model="queryParams.phoneNumber"
          placeholder="请输入手机号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="所属行业" prop="industry">
        <el-select v-model="queryParams.industry" placeholder="请选择所属行业" clearable size="small">
          <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INDUSTRY)"
                       :key="dict.value" :label="dict.label" :value="dict.value"/>
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="创建时间">
        <el-date-picker v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd"
                        type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item> -->
      <el-form-item>
        <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        <el-button
          type="primary"
          icon="el-icon-search"
          @click="handleQuery"
        >搜索</el-button>
      </el-form-item>
    </el-form>
    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          v-hasPermi="['member:company:create']"
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
                   v-hasPermi="['member:company:export']">导出</el-button>
      </el-col> -->
      <right-toolbar
        :show-search.sync="showSearch"
        @queryTable="getList"
      />
    </el-row>
    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
      <el-table-column label="序号" type="index" />
      <el-table-column label="用户名称" align="center" prop="applyUserName" />
      <el-table-column label="企业名称" align="center" prop="companyName" />
      <el-table-column label="部门" align="center" prop="dept" />
      <el-table-column
        label="认证状态"
        align="center"
        prop="authorizedStatus"
      />
      <el-table-column label="手机号" align="center" prop="phoneNumber" />
      <el-table-column
        label="注册时间"
        align="center"
        prop="createTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="最近登录"
        align="center"
        prop="createTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleCheck(scope.row)"
          >查看</el-button>
          <el-button
            v-hasPermi="['member:company:update']"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
          <el-button
            v-hasPermi="['member:company:delete']"
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 新建-步骤一，填写用户信息 -->
    <el-dialog
      :title="title"
      :visible.sync="openUserDialog"
      width="500px"
      append-to-body
    >
      <el-form
        ref="userForm"
        :model="userForm"
        :rules="rules"
        label-width="80px"
      >
        <el-form-item label="企业申请人姓名" prop="applyUserName">
          <el-input
            v-model="userForm.applyUserName"
            placeholder="请输入企业申请人姓名"
          />
        </el-form-item>
        <el-form-item label="企业名称" prop="companyName">
          <el-input
            v-model="userForm.companyName"
            placeholder="请输入企业名称"
          />
        </el-form-item>
        <el-form-item label="手机号" prop="phoneNumber">
          <el-input v-model="userForm.phoneNumber" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="部门" prop="dept">
          <el-input v-model="userForm.dept" placeholder="请输入部门" />
        </el-form-item>
        <el-form-item label="职位" prop="job">
          <el-input v-model="userForm.job" placeholder="请输入职位" />
        </el-form-item>
        <el-form-item label="座机号" prop="tel">
          <el-input v-model="userForm.tel" placeholder="请输入座机号" />
        </el-form-item>
        <el-form-item label="邮箱号" prop="email">
          <el-input v-model="userForm.email" placeholder="请输入邮箱号" />
        </el-form-item>
        <el-form-item label="账户类型">
          <el-select disabled value="1">
            <el-option value="1" label="企业管理员">企业管理员</el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitUserForm">下一步</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 新建-步骤二，填写企业信息 -->
    <el-dialog
      :title="title"
      :visible.sync="openCompanyDialog"
      width="500px"
      append-to-body
    >
      <el-form
        ref="companyForm"
        :model="companyForm"
        :rules="rules"
        label-width="80px"
      >
        <el-form-item label="统一社会信用代码" prop="creditCode">
          <el-input
            v-model="form.creditCode"
            placeholder="请输入统一社会信用代码"
          />
        </el-form-item>
        <el-form-item label="营业执照图片">
          <imageUpload v-model="form.businessLicense" />
        </el-form-item>
        <el-form-item label="行业类型" prop="industryType">
          <el-cascader
            v-model="form.industryType"
            :show-all-levels="false"
            :options="businessAreaData"
            @change="businessAreaChange"
          />
        </el-form-item>
        <el-form-item label="邮政编码" prop="postCode">
          <el-input v-model="form.postCode" placeholder="请输入邮政编码" />
        </el-form-item>
        <el-form-item label="经营状态" prop="businessStatus">
          <el-radio-group v-model="form.businessStatus">
            <el-radio
              v-for="dict in this.getDictDatas(
                DICT_TYPE.COMPANY_BUSINESS_STATUS
              )"
              :key="dict.value"
              :label="dict.value"
            >{{ dict.label }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="注册资本" prop="registeredCapital">
          <el-input
            v-model="form.registeredCapital"
            placeholder="请输入注册资本"
          />
        </el-form-item>
        <el-form-item label="成立日期" prop="establishDate">
          <el-date-picker
            v-model="form.establishDate"
            clearable
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择成立日期"
          />
        </el-form-item>
        <el-form-item label="法定代表人" prop="legalPerson">
          <el-input v-model="form.legalPerson" placeholder="请输入法定代表人" />
        </el-form-item>
        <el-form-item label="子企业关系证明图片">
          <imageUpload
            v-model="form.subCompanyRelationshipCertificatePicture"
          />
        </el-form-item>
        <el-form-item label="子企业关系证明_word">
          <fileUpload v-model="form.subCompanyRelationshipCertificateWord" />
        </el-form-item>
        <el-form-item label="企业规模" prop="scale">
          <el-input v-model="form.scale" placeholder="请输入企业规模" />
        </el-form-item>
        <!-- <el-form-item label="企业状态" prop="status">
          <el-select v-model="form.status" placeholder="请选择企业状态">
            <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMPANY_STATUS)"
                       :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </el-form-item> -->
        <el-form-item label="企业类型" prop="companyType">
          <el-select v-model="form.companyType" placeholder="请选择企业状态">
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.COMPANY_TYPE)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="注册地址" prop="registeredAddress">
          <el-input
            v-model="form.registeredAddress"
            placeholder="请输入注册地址"
          />
        </el-form-item>
        <el-form-item label="经营范围" prop="businessScope">
          <el-input
            v-model="form.businessScope"
            type="textarea"
            placeholder="请输入经营范围"
          />
        </el-form-item>
        <el-form-item label="企业图片">
          <imageUpload v-model="form.companyPicture" />
        </el-form-item>
        <!-- <el-form-item label="企业简称" prop="companyShortName">
          <el-input v-model="form.companyShortName" placeholder="请输入企业简称" />
        </el-form-item> -->
        <el-form-item label="企业logo">
          <imageUpload v-model="form.companyLogo" />
        </el-form-item>
        <el-form-item label="所属行业" prop="industry">
          <el-select v-model="form.industry" placeholder="请选择所属行业">
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.INDUSTRY)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="企业简介" prop="introduction">
          <el-input v-model="form.introduction" placeholder="请输入企业简介" />
        </el-form-item>
        <el-form-item label="企业环境图/视频数组">
          <fileUpload v-model="form.environment" />
        </el-form-item>
        <el-form-item label="企业地址" prop="companyAddress">
          <el-input
            v-model="form.companyAddress"
            placeholder="请输入企业地址"
          />
        </el-form-item>
        <el-form-item label="企业地图坐标(经纬度)" prop="companyCoordinate">
          <el-input
            v-model="form.companyCoordinate"
            placeholder="请输入企业地图坐标(经纬度)"
          />
        </el-form-item>

        <el-form-item label="账户类型">
          <el-select disabled value="1">
            <el-option value="1" label="企业管理员">企业管理员</el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitUserForm">下一步</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 修改 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref=" " :model="form" :rules="rules" label-width="80px">
        <el-form-item label="企业申请人姓名" prop="applyUserName">
          <el-input
            v-model="form.applyUserName"
            placeholder="请输入企业申请人姓名"
          />
        </el-form-item>
        <el-form-item label="手机号" prop="phoneNumber">
          <el-input v-model="form.phoneNumber" placeholder="请输入手机号" />
        </el-form-item>
        <el-form-item label="座机号" prop="tel">
          <el-input v-model="form.tel" placeholder="请输入座机号" />
        </el-form-item>
        <el-form-item label="邮箱号" prop="email">
          <el-input v-model="form.email" placeholder="请输入邮箱号" />
        </el-form-item>
        <el-form-item label="部门" prop="dept">
          <el-input v-model="form.dept" placeholder="请输入部门" />
        </el-form-item>
        <el-form-item label="职位" prop="job">
          <el-input v-model="form.job" placeholder="请输入职位" />
        </el-form-item>
        <el-form-item label="企业名称" prop="companyName">
          <el-input v-model="form.companyName" placeholder="请输入企业名称" />
        </el-form-item>
        <el-form-item label="统一社会信用代码" prop="creditCode">
          <el-input
            v-model="form.creditCode"
            placeholder="请输入统一社会信用代码"
          />
        </el-form-item>
        <el-form-item label="营业执照图片">
          <imageUpload v-model="form.businessLicense" />
        </el-form-item>
        <el-form-item label="行业类型" prop="industryType">
          <el-select v-model="form.industryType" placeholder="请选择行业类型">
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.INDUSTRY_TYPE)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="邮政编码" prop="postCode">
          <el-input v-model="form.postCode" placeholder="请输入邮政编码" />
        </el-form-item>
        <el-form-item label="经营状态" prop="businessStatus">
          <el-radio-group v-model="form.businessStatus">
            <el-radio
              v-for="dict in this.getDictDatas(
                DICT_TYPE.COMPANY_BUSINESS_STATUS
              )"
              :key="dict.value"
              :label="dict.value"
            >{{ dict.label }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="注册资本" prop="registeredCapital">
          <el-input
            v-model="form.registeredCapital"
            placeholder="请输入注册资本"
          />
        </el-form-item>
        <el-form-item label="成立日期" prop="establishDate">
          <el-date-picker
            v-model="form.establishDate"
            clearable
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择成立日期"
          />
        </el-form-item>
        <el-form-item label="法定代表人" prop="legalPerson">
          <el-input v-model="form.legalPerson" placeholder="请输入法定代表人" />
        </el-form-item>
        <el-form-item label="企业规模" prop="scale">
          <el-input v-model="form.scale" placeholder="请输入企业规模" />
        </el-form-item>
        <el-form-item label="企业状态" prop="status">
          <el-select v-model="form.status" placeholder="请选择企业状态">
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.COMPANY_STATUS)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="企业类型" prop="companyType">
          <el-select v-model="form.companyType" placeholder="请选择企业状态">
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.COMPANY_TYPE)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="企业图片">
          <imageUpload v-model="form.companyPicture" />
        </el-form-item>
        <el-form-item label="注册地址" prop="registeredAddress">
          <el-input
            v-model="form.registeredAddress"
            placeholder="请输入注册地址"
          />
        </el-form-item>
        <el-form-item label="经营范围" prop="businessScope">
          <el-input
            v-model="form.businessScope"
            type="textarea"
            placeholder="请输入经营范围"
          />
        </el-form-item>
        <el-form-item label="企业简称" prop="companyShortName">
          <el-input
            v-model="form.companyShortName"
            placeholder="请输入企业简称"
          />
        </el-form-item>
        <el-form-item label="企业logo">
          <imageUpload v-model="form.companyLogo" />
        </el-form-item>
        <el-form-item label="所属行业" prop="industry">
          <el-select v-model="form.industry" placeholder="请选择所属行业">
            <el-option
              v-for="dict in this.getDictDatas(DICT_TYPE.INDUSTRY)"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="企业简介" prop="introduction">
          <el-input v-model="form.introduction" placeholder="请输入企业简介" />
        </el-form-item>
        <el-form-item label="企业环境图/视频数组">
          <fileUpload v-model="form.environment" />
        </el-form-item>
        <el-form-item label="企业地址" prop="companyAddress">
          <el-input
            v-model="form.companyAddress"
            placeholder="请输入企业地址"
          />
        </el-form-item>
        <el-form-item label="企业地图坐标(经纬度)" prop="companyCoordinate">
          <el-input
            v-model="form.companyCoordinate"
            placeholder="请输入企业地图坐标(经纬度)"
          />
        </el-form-item>
        <el-form-item label="子企业关系证明图片">
          <imageUpload
            v-model="form.subCompanyRelationshipCertificatePicture"
          />
        </el-form-item>
        <el-form-item label="子企业关系证明_word">
          <fileUpload v-model="form.subCompanyRelationshipCertificateWord" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  createCompany,
  updateCompany,
  deleteCompany,
  getCompany,
  getCompanyPage,
  exportCompanyExcel
} from '@/api/member/company'
import ImageUpload from '@/components/ImageUpload'
import FileUpload from '@/components/FileUpload'
import businessAreaData from '@/utils/businessAreaData.js'
export default {
  name: 'Company',
  components: {
    ImageUpload,
    FileUpload
  },
  data() {
    const validatePhone = (rule, value, callback) => {
      const phoneReg = /^[1][0-9]{10}$/
      if (value === '') {
        return callback(new Error('手机号不能为空'))
      } else {
        if (phoneReg.test(value)) {
          return callback()
        } else {
          return callback(new Error('格式有误'))
        }
      }
    }
    const validataEmail = (rule, value, callback) => {
      const emailReg =
        /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
      if (value === '') {
        return callback()
      } else {
        if (emailReg.test(value)) {
          return callback()
        } else {
          return callback(new Error('格式有误'))
        }
      }
    }
    return {
      // 企业行业类型数据，二级联动
      businessAreaData: businessAreaData,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 企业管理列表
      list: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        applyUserName: null,
        phoneNumber: null,
        companyName: null,
        status: null,
        industry: null
      },
      // 表单参数
      form: {},
      // 用户信息表
      userForm: {
        applyUserName: '',
        dept: '',
        job: '',
        tel: '',
        email: '',
        companyName: '',
        phoneNumber: ''
      },
      // 企业信息表
      companyForm: {
        creditCode: '', // 统一信用代码
        businessLicense: '', // 营业执照
        industryType: '', // 行业类型
        postCode: '', // 邮政编码
        businessStatus: '', // 经营状态
        registeredCapital: '', // 注册资本
        establishDate: '', // 成立日期
        legalPerson: '', // 法人
        subCompanyRelationshipCertificatePicture: '', // 子母企业关系证明
        scale: '', // 企业规模
        companyType: '', // 企业类型
        registeredAddress: '', // 注册地址
        businessScope: '', // 经营范围
        environment: '' // 企业图片，支持图片、视频，数组格式
      },
      // 表单校验
      rules: {
        applyUserName: [
          {
            required: true,
            message: '企业申请人姓名不能为空',
            trigger: 'blur'
          }
        ],
        phoneNumber: [
          { required: true, validator: validatePhone, trigger: 'blur' }
        ],
        tel: [{ required: false, message: '座机号不能为空', trigger: 'blur' }],
        email: [{ required: false, validator: validataEmail, trigger: 'blur' }],
        dept: [{ required: false, message: '部门不能为空', trigger: 'blur' }],
        job: [{ required: false, message: '职位不能为空', trigger: 'blur' }],
        companyName: [
          { required: true, message: '企业名称不能为空', trigger: 'blur' }
        ],
        creditCode: [
          {
            required: true,
            message: '统一社会信用代码不能为空',
            trigger: 'blur'
          }
        ],
        businessLicense: [
          {
            required: true,
            message: '营业执照图片不能为空',
            trigger: 'blur'
          }
        ],
        industryType: [
          { required: true, message: '行业类型不能为空', trigger: 'change' }
        ],
        postCode: [
          { required: true, message: '邮政编码不能为空', trigger: 'blur' }
        ],
        businessStatus: [
          { required: true, message: '经营状态不能为空', trigger: 'blur' }
        ],
        registeredCapital: [
          { required: true, message: '注册资本不能为空', trigger: 'blur' }
        ],
        establishDate: [
          { required: true, message: '成立日期不能为空', trigger: 'blur' }
        ],
        legalPerson: [
          { required: true, message: '法定代表人不能为空', trigger: 'blur' }
        ],
        scale: [
          { required: true, message: '企业规模不能为空', trigger: 'blur' }
        ],
        status: [
          { required: true, message: '企业状态不能为空', trigger: 'change' }
        ],
        companyType: [
          { required: true, message: '企业类型不能为空', trigger: 'change' }
        ],
        companyPicture: [
          { required: true, message: '企业图片不能为空', trigger: 'blur' }
        ],
        registeredAddress: [
          { required: true, message: '注册地址不能为空', trigger: 'blur' }
        ],
        businessScope: [
          { required: true, message: '经营范围不能为空', trigger: 'blur' }
        ],
        companyShortName: [
          { required: true, message: '企业简称不能为空', trigger: 'blur' }
        ],
        companyLogo: [
          { required: true, message: '企业logo不能为空', trigger: 'blur' }
        ],
        industry: [
          { required: true, message: '所属行业不能为空', trigger: 'change' }
        ],
        environment: [
          {
            required: true,
            message: '企业环境图/视频数组不能为空',
            trigger: 'blur'
          }
        ],
        companyAddress: [
          { required: true, message: '企业地址不能为空', trigger: 'blur' }
        ],
        companyCoordinate: [
          {
            required: true,
            message: '企业地图坐标(经纬度)不能为空',
            trigger: 'blur'
          }
        ],
        subCompanyRelationshipCertificatePicture: [
          {
            required: true,
            message: '子企业关系证明图片不能为空',
            trigger: 'blur'
          }
        ],
        subCompanyRelationshipCertificateWord: [
          {
            required: true,
            message: '子企业关系证明_word不能为空',
            trigger: 'blur'
          }
        ]
      },
      openUserDialog: false, // 用户信息弹窗
      openCompanyDialog: false
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 企业行业类型修改
    businessAreaChange(value) {
    },
    /** 查询列表 */
    getList() {
      this.loading = true
      // 处理查询参数
      const params = { ...this.queryParams }
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')
      // 执行查询
      getCompanyPage(params).then((response) => {
        this.list = response.data.list
        this.total = response.data.total
        this.loading = false
      })
    },
    submitUserForm() {
      this.$refs.userForm.validate((boo) => {
        if (boo) {
          this.openUserDialog = false
          this.openCompanyDialog = true
        }
      })
    },
    /** 取消按钮 */
    cancel() {
      this.openUserDialog = false
      this.open = false
      this.reset()
    },
    /** 表单重置 */
    reset() {
      this.form = {
        applyUserName: undefined,
        phoneNumber: undefined,
        tel: undefined,
        email: undefined,
        dept: undefined,
        job: undefined,
        companyName: undefined,
        creditCode: undefined,
        businessLicense: undefined,
        industryType: undefined,
        postCode: undefined,
        businessStatus: undefined,
        registeredCapital: undefined,
        establishDate: '',
        legalPerson: undefined,
        scale: undefined,
        status: undefined,
        companyType: undefined,
        companyPicture: undefined,
        registeredAddress: undefined,
        businessScope: undefined,
        companyShortName: undefined,
        companyLogo: undefined,
        industry: undefined,
        introduction: undefined,
        environment: undefined,
        companyAddress: undefined,
        companyCoordinate: undefined,
        subCompanyRelationshipCertificatePicture: undefined,
        subCompanyRelationshipCertificateWord: undefined
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreateTime = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset()
      this.openUserDialog = true
      this.title = '新建企业用户'
    },
    /** 打开企业详情页面 */
    handleCheck(row) {
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset()
      const id = row.id
      getCompany(id).then((response) => {
        response.data.establishDate = response.data.establishDate + ''
        this.form = response.data
        this.title = '修改企业管理'
        setTimeout(() => {
          this.open = true
        })
      })
    },
    // 查看按钮操作
    handleUpdate(row) {
      this.reset()
      const id = row.id
      getCompany(id).then((response) => {
        this.form = response.data
        this.open = true
        this.title = '修改企业管理'
      })
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (!valid) {
          return
        }
        // 修改的提交
        if (this.form.id != null) {
          updateCompany(this.form).then((response) => {
            this.$modal.msgSuccess('修改成功')
            this.open = false
            this.getList()
          })
          return
        }
        // 添加的提交
        createCompany(this.form).then((response) => {
          this.$modal.msgSuccess('新增成功')
          this.open = false
          this.getList()
        })
      })
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const companyName = row.companyName
      this.$modal
        .confirm('是否确认删除企业名为"' + companyName + '"的数据项?')
        .then(function() {
          return deleteCompany(id)
        })
        .then(() => {
          this.getList()
          this.$modal.msgSuccess('删除成功')
        })
        .catch(() => {})
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      const params = { ...this.queryParams }
      params.pageNo = undefined
      params.pageSize = undefined
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')
      // 执行导出
      this.$modal
        .confirm('是否确认导出所有企业数据项?')
        .then(() => {
          this.exportLoading = true
          return exportCompanyExcel(params)
        })
        .then((response) => {
          this.$download.excel(response, '${table.classComment}.xls')
          this.exportLoading = false
        })
        .catch(() => {})
    }
  }
}
</script>
